package com.jxzyk.http;

import android.text.TextUtils;

import com.core.entity.params.MapParams;
import com.core.entity.params.ReqParams;

public class Query {
	private String keywords;// 关键字
	private int length;// 分页长度
	private int page = -1;// 页码
	private static String KEY_KEYWORDS = "keywords";
	private static String KEY_LENGTH = "length";
	private static String KEY_PAGE = "page";

	public String getKeywords() {
		return keywords;
	}

	public void setKeywords(String keywords) {
		this.keywords = keywords;
	}

	public int getLength() {
		return length;
	}

	public void setLength(int length) {
		this.length = length;
	}

	public int getPage() {
		return page;
	}

	public void setPage(int page) {
		this.page = page;
	}

	public ReqParams toParams() {
		ReqParams params = new MapParams();
		if (!TextUtils.isEmpty(keywords)) {
			params.put(KEY_KEYWORDS, keywords);
		}
		if (length > 0) {
			params.put(KEY_LENGTH, length);
		}
		if (page >= 0) {
			params.put(KEY_PAGE, page);
		}
		return params;
	}
}
